package com.cattest.cattest.controller;

import com.cattest.cattest.entity.UserEntity;
import com.cattest.cattest.service.UserService;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author linlx
 * @Date 2021/8/21 16:47
 * @Description
 **/
@RestController
public class UserController {

  @Resource
  private UserService userService;

  @GetMapping("/mybatis/query")
  public UserEntity query(@RequestParam Integer id) {
    return userService.selectById(id);
  }

  @GetMapping("/mybatis/update")
  public String update(@RequestParam Integer id, @RequestParam String realName) {
    userService.updateById(id, realName);
    return "ok";
  }

  @GetMapping("/mybatis/delete")
  public String delete(@RequestParam Integer id) {
    userService.deleteById(id);
    return "ok";
  }

  @GetMapping("/mybatis/save")
  public String save(@RequestParam String userName, @RequestParam String passWord,
      @RequestParam String realName) {
    userService.save(userName, passWord, realName);
    return "ok";
  }

}
